package com.example.demo.mapper;

import com.example.demo.entity.Notification;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NotificationMapper {
    @Insert("INSERT INTO notifications (user_id, content) VALUES (#{user_id}, #{content})")
    void insertNotification(@Param("user_id") int user_id, @Param("content") String content);

    @Select("SELECT * FROM notifications WHERE user_id = #{user_id} ORDER BY created_at DESC")
    List<Notification> findNotificationsByUserId(@Param("user_id") int user_id);

    @Update("UPDATE notifications SET is_read = TRUE WHERE notification_id = #{notification_id} AND user_id = #{user_id}")
    void updateNotificationReadStatus(@Param("user_id") int user_id, @Param("notification_id") int notification_id);


    @Select("SELECT * FROM notifications WHERE notification_id = #{notification_id}")
    Notification findNotificationById(@Param("notification_id") int notification_id);

}